package com._520it.crm.web.controller;

import com._520it.crm.domain.FollowupBill;
import com._520it.crm.page.AjaxResult;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.FollowupBillQueryObject;
import com._520it.crm.service.IFollowupBillService;
import com._520it.crm.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/followupBill")
public class FollowupBillController {
	@Autowired
	private IFollowupBillService followupBillService;
	@RequiresPermissions("followupBill:index")
	@PermissionName("客户跟进明细列表")
	@RequestMapping("")
	public String index(){
		return "followupBill";
	}
	@RequiresPermissions("followupBill:list")
	@PermissionName("客户跟进明细数据")
	@RequestMapping("/list")
	@ResponseBody
	public PageResult list(FollowupBillQueryObject qo){
		PageResult result = followupBillService.queryPage(qo);
		return result;
	}
	@RequiresPermissions("followupBill:save")
	@RequestMapping("/save")
	@ResponseBody
	@PermissionName("客户跟进明细新增")
	public AjaxResult save(FollowupBill followupBill){
		AjaxResult result = null;
		try{
			followupBillService.insert(followupBill);
			result = new AjaxResult(true,"保存成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("保存失败,请联系管理员!");
		}
		return result;
	}
	@RequiresPermissions("followupBill:update")
	@PermissionName("客户跟进明细更新")
	@RequestMapping("/update")
	@ResponseBody
	public AjaxResult update(FollowupBill followupBill){
		AjaxResult result = null;
		try{
			followupBillService.updateByPrimaryKey(followupBill);
			result = new AjaxResult(true,"更新成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("更新失败,请联系管理员!");
		}
		return result;
	}
	@RequiresPermissions("followupBill:delete")
	@PermissionName("客户跟进明细删除")
	@RequestMapping("/delete")
	@ResponseBody
	public AjaxResult delete(Long followupBillId){
		AjaxResult result = null;
		try{
			followupBillService.deleteByPrimaryKey(followupBillId);
			result = new AjaxResult(true,"删除成功");
		}catch(Exception e){
			e.printStackTrace();
			result = new AjaxResult("删除失败,请联系管理员!");
		}
		return result;
	}
}
